
public class ArraySorter{

	public synchronized static long ordenar() {
		String array[] = { "a", "j", "c", "k", "u", "b", "b", "i", "g", "f" };
		String a = "";
		long start, end;
		
		// Impressao do array desordenado
		for (String s : array)
			a += " " + s;
		
		System.out.print("Antes: " + a);
		a = "";
		
		start = System.currentTimeMillis();
		
		for (int i = 0; i < array.length - 1; i++) {
			for (int c = 0; c < array.length - 1; c++){
				if (array[c].compareTo(array[c+1]) > 0){
					String auxiliar = array[c];
					array[c] = array[c + 1];
					array[c + 1] = auxiliar;
				}
			}
		}
		
		end = System.currentTimeMillis();
		
		// Impressao do array ordenado
		for (String s : array)
			a += " " + s;
		
		System.out.println("\tDepois: " + a);
		a = "";
		
		return end - start;
	}
	
}
